//
// Created by Jisam on 2024/8/17 19:04.
// Solution of  a
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

#define endl "\n"
#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
#define ui unsigned
#define lli long long
#define ulli unsigned long long
#define code_by_jisam ios::sync_with_stdio(false),cin.tie(nullptr)
using namespace std;


void solution() {
    int i;
    cin >> i;
    vector<int> a = {0, 0, 1, 1};
    if (i < 4) {
        cout << a[i] << endl;
    } else {
        if (i % 3 == 0 || i % 2 == 0) {
            cout << 2 << endl;
        } else {
            cout << 3 << endl;
        }
    }

}

int main() {
    code_by_jisam;
    int T = 1;
    cin >> T;
    while (T--) {
        solution();
    }
    return 0;
}